<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>判断一个数是否是素数</title>
</head>

<body>
    <script>
        function isZhiShu(n) {
            var isZS = true;
            for (var i = 2; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    isZS = false;
                }
            }
            if (isZS == true) {
                return n + "是素数";
            } else {
                return n + "不是素数";
            }
        }
        var n = parseInt(prompt("请输入n的值"));
        alert(isZhiShu(n));
    </script>
</body>

</html>